{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">新增物料</h3>
    <table class="layui-table layui-table-form">
        {if condition="$eid gt 0"}
        <input type="hidden" name="eid" value="{$eid}" lay-verify="required">
        {else/}
        <tr>
        <td class="layui-td-gray">所在企业<font>*</font></td>
        <td colspan="3">
            <select name="eid" lay-verify="required" lay-reqText="请选择所属企业">
                <option value="0">系统管理员</option>
                {volist name="enterprise" id="v"}
                <option value="{$v.id}" {notempty name="$detail.eid"} {eq name="$v.id" value="$detail.eid"} selected{/eq}{/notempty} >{$v.title}</option>
                {/volist}
            </select>
        </td>
        </tr>
        {/if}
      <tr>
          <td class="layui-td-gray">物料名称<font>*</font></td>
          <td colspan="5"><input type="text" name="name" lay-verify="required" {notempty name="$detail.name"}value="{$detail.name}" {/notempty} lay-reqText="请输入物料名称" autocomplete="off" placeholder="请输入物料名称" class="layui-input"></td>

      </tr>
        <tr>
            <td class="layui-td-gray">仓库<font>*</font></td>
            <td >
                <input type="text" name="warehouse" lay-verify="required" {notempty name="$detail.warehouse"}value="{$detail.warehouse}"
                       {/notempty} lay-reqText="请输入物料仓库" autocomplete="off" placeholder="请输入物料仓库" class="layui-input"></td>
            </td>
            <td class="layui-td-gray">规格型号<font>*</font></td>
            <td >
                <input type="text" name="version" lay-verify="required" {notempty name="$detail.version"}value="{$detail.version}"
                       {/notempty} lay-reqText="请输入物料规格型号" autocomplete="off" placeholder="请输入物料规格型号" class="layui-input"></td>
            </td>
        </tr>

        <tr>
            <td class="layui-td-gray">数量<font>*</font></td>
            <td >
                <input type="number" name="num" lay-verify="required" {notempty name="$detail.num"}value="{$detail.num}"
                       {/notempty} lay-reqText="请输入物料数量" autocomplete="off" placeholder="请输入物料数量" class="layui-input"></td>
            </td>
            <td class="layui-td-gray">单位<font>*</font></td>
            <td >
                <input type="text" name="unit" lay-verify="required" {notempty name="$detail.unit"}value="{$detail.unit}"
                       {/notempty} lay-reqText="请输入物料单位" autocomplete="off" placeholder="请输入物料单位" class="layui-input"></td>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">单价(资产原值)元<font>*</font></td>
            <td >
                <input type="number" name="price" lay-verify="required" {notempty name="$detail.price"}value="{$detail.price}"
                       {/notempty} lay-reqText="请输入物料单价" autocomplete="off" placeholder="请输入物料单价" class="layui-input"></td>
            </td>
            <td class="layui-td-gray">物料编码<font>*</font></td>
            <td>
                <input type="text" name="code" lay-verify="required" {notempty name="$detail.code"}value="{$detail.code}"
                       {/notempty} lay-reqText="请输入物料编码" autocomplete="off" placeholder="请输入物料编码" class="layui-input"></td>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">出库日期<font>*</font></td>
            <td>
                <input id="out_time" name="out_time" autocomplete="off"
                       {notempty name="$detail.fmt_out_time"}value="{$detail.fmt_out_time}"
                       {/notempty}  class="layui-input" value="" readonly lay-verify="required"
                placeholder="请选择出库日期" lay-reqText="请选择出库日期">
            </td>
            <td class="layui-td-gray">出库单号<font>*</font></td>
            <td>
                <input type="text" name="out_code" lay-verify="required" {notempty name="$detail.out_code"}value="{$detail.out_code}"
                       {/notempty} lay-reqText="请输入出库单号" autocomplete="off" placeholder="请输入出库单号" class="layui-input"></td>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">出库类别<font>*</font></td>
            <td>
                <input type="text" name="out_type" lay-verify="required" {notempty name="$detail.out_type"}value="{$detail.out_type}"
                       {/notempty} lay-reqText="请输入出库类别" autocomplete="off" placeholder="请输入出库类别" class="layui-input"></td>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">物料简介<span style="color: red">*</span></td>
            <td colspan="3">
                <textarea name="remark"  class="layui-textarea" lay-verify="required" lay-reqText="请完善物料简介">{notempty name="$detail.remark"}{$detail.remark}{/notempty}</textarea>
            </td>
        </tr>
        <input type="hidden" name="id" ,  {notempty name="$detail.id"}value="{$detail.id}" {/notempty} >
    </table>
    <div class="py-3">
	   <input type="hidden" name="scene" value="add">
      <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','employeepicker'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,employeepicker = layui.employeepicker;
		
		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/home/goods/add", data.field, callback);
			return false;
		});

        var form = layui.form,
            tool=layui.tool,
            oaTool=layui.oaTool,
            laydate = layui.laydate;
        //日期时间范围
        laydate.render({
            elem: '#out_time',
            type: 'date',
            format: 'yyyy-MM-dd',
            showBottom: false
        });

    }
</script>
{/block}
<!-- /脚本 -->